<{include file="_head.html"}>
<script type="text/javascript" src="js/jquery.qqFace.js"></script> 
<script type="text/javascript">
$(function(){
	
})
</script>
<{include file="head.html"}>
<script type="text/javascript">
$(function(){
	//添加、删除关注
	$(".a_gzt").click(function(){
		var url='info_detail.php?id=<{$smarty.get.id}>&action=addFocus';
		var isfocus=$(this).attr("isfocus");
		isfocus=isfocus=='is'?'no':'is';
		$.post(
			url,
			{isfocus:isfocus},
			function(data){
				if(data.error==1){
					alert(data.msg);
					$('.a_gzt').attr("isfocus",isfocus);
					$('.a_gzt').html(data.title);
				}else{
					alert(data.msg);
					if(data.error==2){
						window.location.href="login.php";
					}
				}
			},'json'
			)
	})

	//点赞
	$(".a3_nry").click(function(){
		var info_id=$(this).attr("info_id");
			$.post(
		        'ajax.php?action=addZan',
		        {info_id:info_id},
		        function(data){
		          if(data.res==1){
		            alert(data.mes);
		          }else{
		            alert("请先登录！");
		            window.location.href="login.php";
		          }
		    },"json")
	})

	//取消点赞
	$(".a4_nry").click(function(){
		// var uid = getCookie('user_id');
		var info_id=$(this).attr("info_id");
			$.post(
		        'ajax.php?action=cutZan',
		        {info_id:info_id},
		        function(data){
		          if(data.res==1){
		            alert(data.mes);
		          }else{
		            alert("请先登录！");
		            window.location.href="login.php";
		          }
		    },"json")
	})

	 //添加、取消收藏
    $(".collect").click(function(){
      var isId=$(this).attr("isId");
      var newclass=isId==''?'collect a1_nry':'collect a1_nry1';
      var url='info_detail.php?id=<{$smarty.get.id}>&action=collect';
      $.post(
        url,
        {isId:isId},
        function(data){
          if(data.error==1){
            alert(data.msg);
            $(".collect").attr('isId',data.isId);
            $(".collect").attr('class',newclass)
          }
        },'json'
        )
    })

    /***评论JS****/
    //匹配表情-初始化
    $('.neirong').each(function(){
        var text=$(this).html();
        $(this).html(replace_em(text));
    })

    //回复用户效果变更
    $(".a_huifu1").live('click',function(){
      var user_id=$(this).attr("user_id");	//用户ID
      var name=$(this).attr("name");		//被回复人名称
      var user_type=$(this).attr("user_type");//被回复人类型

      $("#huifuren").html('to reply to '+name);
      $(".reply_id").val(user_id);
      $(".user_type").val(user_type);

    })

    //限制输入字数
    $(".text_ly").keyup(function(){
      var num='140'; //设置最大输入数
      var length=$(this).val().length;
      var shengyu=num-length
      $(".span_shuru").html('还可以输入'+shengyu+'字');
    })

    //评论
    $(".a_pinglun").click(function(){
      var reply_id=$(".reply_id").val();	//回复ID
      var comment=$(".text_ly").val();		//回复内容
      var info_id='<{$detail.id}>';			//信息ID
      var user_type=$(".user_type").val();	//回复的类型

      $.post(
            'info_detail.php?action=comment',
            {comment:comment,reply_id:reply_id,info_id:info_id,user_type:user_type},
            function(data){
              if(data.error==1){
                alert(data.mes);
                $(".pinglun").eq(0).before(data.html);
                //替换表情
                var str = $(".neirong").eq(0).html();
                $(".neirong").eq(0).html(replace_em(str));
                //重置样式跟属性
                $(".text_ly").val('');
                $("#huifuren").html('');
                $(".reply_id").val(0);

              }else{
                alert("请先登录！");
                window.location.href="login.php";
              }
        },"json")
    })

	 //表情特效
	  $('.emotion').qqFace({ // 
	    id : 'facebox', //表情盒子的ID
	    assign:'saytext', //给那个控件赋值
	    path:'images/face/' //表情存放的路径，注意如果修改了这个地方，下面正则匹配的地方也要做相应的修改
	  });

})	

//表情替换
function replace_em(str){
    str = str.replace(/\</g,'&lt;');
    str = str.replace(/\>/g,'&gt;');
    str = str.replace(/\n/g,'<br/>');
    str = str.replace(/\[em_([0-9]*)\]/g,'<img src="images/face/$1.gif" border="0" />');
    return str;
}

</script>

<div class="main">
<!-- left -->
<div class="main_left">
<div class="main_left_top">
	<{if $search.title==''}>
	<ul class="ul_main_left_top">
		<li><a <{if $detail.class_id==''}> class="active" style="color:#FFFFFF"<{/if}> href="info_list.php">全部</a></li>
		<{foreach item=loop from=$info_class}>
		<li><a <{if $detail.class_id==$loop.id}> class="active" style="color:#FFFFFF"<{/if}> href="info_list.php?class_id=<{$loop.id}>"><{$loop.class_name}></a></li> 
		<{/foreach}>
	</ul>
	<{else}>
	<span class="span_weizhi">搜索关键字：<{$search.title}></span>
	<{/if}>
</div>
<div class="clear"></div>
<div class="main_left_nr_nry">

<span class="span_nry_bt"><{$detail.title}></span>
<div class="nry_bt">
<span><{$detail.createTime}></span>
<ul class="ul_nry_bt">
<li><a href="javascript:;" isId="<{$detail.is_collect.id}>" <{if $detail.is_collect.id}>class="a1_nry collect"><{else}> class="a1_nry1 collect"><{/if}>&nbsp;</a></li>
<!-- <li><a href="#" class="a2_nry">&nbsp;</a></li> -->
<li><a href="javascript:;" class="a3_nry" info_id="<{$loop.id}>">&nbsp;</a></li>
<li><a href="javascript:;" class="a4_nry" info_id="<{$loop.id}>">&nbsp;</a></li>
<li><a href="#" class="a5_nry">&nbsp;</a></li>
</ul>
</div>

<div class="main_left_nr_nry_text">
<{$detail.intro}>
</div>

<div class="fx_nav">
<!-- <img src="images/fx_img.jpg" width="175" height="28" style="display:block; float:left;" /> -->
 	<!-- JiaThis Button BEGIN -->
    <div class="jiathis_style" style=" float:left; display:inline; padding:10px 0; margin-left:10px; overflow:hidden;">
        <span class="jiathis_txt">分享到：</span>
        <a class="jiathis_button_icons_1"></a>
        <a class="jiathis_button_icons_2"></a>
        <a class="jiathis_button_icons_3"></a>
        <a class="jiathis_button_icons_4"></a>
        <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jtico jtico_jiathis" target="_blank"></a>
        <a class="jiathis_counter_style"></a>
    </div>
    <script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
    <!-- JiaThis Button END -->
<!-- <ul class="ul_nry_bt">
<li><a href="#" class="a1_nry">&nbsp;</a></li>
<li><a href="#" class="a2_nry">&nbsp;</a></li>
<li><a href="javascript:;" class="a3_nry" info_id="<{$loop.id}>">&nbsp;</a></li>
<li><a href="javascript:;" class="a4_nry" info_id="<{$loop.id}>">&nbsp;</a></li>
<li><a href="#" class="a5_nry">&nbsp;</a></li>
</ul> -->

</div>
<span class="span_xbs">小编说</span>
	<ul class="ul_xbs">
		<{foreach item=res from=$topics}>
		<li><a href="#"><{$res.topic}></a></li>
		<{/foreach}>

	</ul>	  

<span class="span_dlzc" id="F1"><a href="#">登录</a>|<a href="#">注册</a></span>
<span class="span_shuru">还可以输入140字</span>
<div class="liuyan">
<img src="images/tx_img.jpg" width="75" height="80" style="display:block; float:left;" />
<div class="liuyan_r">
<textarea name="comment" cols="" rows="" class="text_ly" id="saytext" maxlength="140"></textarea>

<!--新增-->
<span  id="huifuren"></span>
<input type='hidden' name='reply_id' class="reply_id" value="0" />
<input type='hidden' name='user_type' class="user_type" value="user" />
<!--新增-->

<ul class="ul_biaoqing">
<li style="margin-right:38px;"><a href="javascript:;" class="a_biaoqing emotion">表情</a></li>
<li><input name="" type="checkbox" value="" />&nbsp;同步到微薄</li>
</ul>
<a href="javascript:;" class="a_pinglun">评论</a>
</div>
</div>
<span class="span_plsl"><{$commentNum}>条评论</span>

<{if $commentNum==0}>
<span class="span_qsf">还没有人评论过，赶紧抢沙发吧！</span>
<{else}>
	<{foreach item=loop from=$comment}>
     <div class="pinglun"> <img src="upload/<{$loop.userImg}>" width="45" height="45" style="display:block; float:left;" />
        <div class="pinglun_r">
          <div class="pinglun_r_left"> <span><b><a href="user_main.php?type=<{$loop.type}>&id=<{$loop.user_id}>"><{$loop.userName}></a>：<{if $loop.reply_id>0}>回复&nbsp;@<a href="user_main.php?type=<{$loop.reply_type}>&id=<{$loop.reply_id}>"><{$loop.replyName}></a>：<{/if}></b><span class="neirong"><{$loop.comment}></span></span>
            <p><{$loop.create_time}></p>
          </div>
          <ul class="ul_pinglun_r">
            <li><a href="#F1" class="a_huifu1" user_id="<{$loop.user_id}>" name="<{$loop.userName}>" user_type="<{$loop.type}>">回复</a></li>
          </ul>
        </div>
      </div>
  <{/foreach}>
<{/if}>


</div>
</div>
<!-- left -->
<!-- right -->
<div class="main_right">
<span class="span_bq">作者</span>
<div class="zuozhe">
<a href="#"><img src="upload/<{$detail.type}>/small/<{$admin.avatar}>" width="101" height="101" style="display:block; float:left;" /></a>
<div class="zuozhe_right">
<a href="user_main.php?type=<{$detail.type}>&id=<{$admin.id}>" class="a_zuozhe"><{if $detail.type=='admin'}>小编：<{/if}><{$admin.name}></a>
<p><{$admin.intro}></p>
</div>
</div>
<div class="clear"></div>

<a href="javascript:;" <{if $isFocus.id==''}>isfocus="no"<{else}>isfocus="is"<{/if}> class="a_gzt"><{if $isFocus.id==''}>关注TA<{else}>取消关注<{/if}></a>

<div class="zzfbdwz">
<div class="zzfbdwz_top"><span>作者发布的文章</span><a href="user_main.php?type=<{$detail.type}>&id=<{$admin.id}>">more &gt;&gt;</a></div>
<div class="clear"></div>
<ul class="ul_zzfbdwz">
<{foreach item=res from=$ownInfos}>
<li><a href="info_detail.php?id=<{$res.id}>"><{$res.title}></a></li>
<{/foreach}>
</ul>
</div>

<a href="info_apply.php" class="a_wztg">文章投稿&gt;&gt;</a>

</div>
<!-- right -->
</div>
<{include file="footer.html"}>
